import React, { useEffect } from 'react';

interface ITodo {
    done: boolean;
    id: number;
    text: string;
}

const todo: ITodo = {
    done: true,
    id: 1,
    text: 'hello world',   
}


const Keyof = () => {

    const getProp = <T extends object, K extends keyof T>(obj: T, key: K) => {
        return obj[key]
    }

    useEffect(() => {
        console.log(getProp(todo, 'id'));
        console.log(getProp(todo, 'text'));
        console.log(getProp(todo, 'done'));
    }, [])

    return <div>keyof</div>
}

export default Keyof